

$(document).ready(function(){
	
	 initFileInput("fileupload", urlcore + "/api/attachment/upload", "#picturesUrl");
});



function onSave(){
	
   var flag = $('#formMsg').valid();
	if(!checkMobile($("#phone").val())){
		flag = false;
		return;
	}
	if(!checkNumber($("#profitability").val())){
		flag = false;
		return;
	}
	var formData = $("#formMsg").serializeJSON(); 
	  var avatarUrl = "";
    $("#picturesUrl img").each(function(index,item){
		avatarUrl += $(this).attr("src")+"***";
	});
	if(avatarUrl!=""){
		  avatarUrl = avatarUrl.substring(0, avatarUrl.length-3);
	}
	
	formData.avatarUrl=avatarUrl;
	if(flag){
			$.ajax({
			url: urlcore + "/api/introducer/add",
			type: "post",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			data: JSON.stringify(formData),
			processData: false,
			success:function(data){
				if(data.success == true){
					alert("添加成功")
					location.href="introducer_list.html";
				}else{
					alert(data.msg);
				}
			},
			error:function() {
				/*alert("error");*/
			}
		});
		
	}
	 
	
	
	
}
